import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, BaseEntity } from 'typeorm';

export enum UserTokenTypeEnum {
    USER = 0,
    CREDITER = 1,
}

export enum UserTokenStatusEnum {
    DISABLE = 0,
    ENABLE = 1,
}

//用户token记录，包含用户和信贷经理
@Entity('user_token')
export class UserToken extends BaseEntity {

    @PrimaryGeneratedColumn()
    id: number;

    @Column({
        width: 11,
        comment: "用户id"
    })
    user_id: number;

    @Column({
        length: 50,
        comment: "token"
    })
    token: string;

    @Column({
        width: 5,
        default: UserTokenStatusEnum.ENABLE,
        comment: "状态，0无效，1有效"
    })
    status: number;

    @Column({
        width: 5,
        default: UserTokenTypeEnum.USER,
        comment: "类型，0是用户，1是信贷经理"
    })
    type: number;

    @CreateDateColumn({
        comment: "创建时间"
    })
    create_time: Date;

    @Column({
        comment: "过期时间"
    })
    expire_time: Date;

    @UpdateDateColumn({
        comment: "更新时间"
    })
    update_time: Date;

}